package com.egao.common.publicly;

import cn.hutool.core.util.StrUtil;
import com.egao.common.core.web.JsonResult;
import com.egao.common.publicly.service.PubliclyLectureSignInService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 讲座签到
 * @author pyx
 * @date 2021/4/30
 */
@Api(tags = "讲座签到")
@RestController
@RequestMapping("${api}")
public class PubliclyLectureSignInController {
    @Autowired
    private PubliclyLectureSignInService publiclyLectureSignInService;

    @ApiOperation("根据code和讲座id获取讲座报名信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "学生code", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "lectureId", value = "讲座id", required = true, dataType = "int", paramType = "query"),
    })
    @GetMapping("/publicly/lecture/signin")
    public JsonResult signIn(String code,Integer lectureId){
        if(StrUtil.isBlank(code) || lectureId == null){
            return JsonResult.error("参数为空");
        }
        return publiclyLectureSignInService.signIn(code,lectureId);
    }

    @ApiOperation("报名讲座")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "studentId", value = "学生id", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "lectureId", value = "讲座id", required = true, dataType = "int", paramType = "query"),
    })
    @PostMapping("/publicly/lecture/signin/apply")
    public JsonResult signInApply(Integer studentId,Integer lectureId){
        return publiclyLectureSignInService.applyLecture(studentId,lectureId);
    }

}
